load("@bazel_skylib//rules:common_settings.bzl", "string_flag")
load("@rules_cc//cc:defs.bzl", "cc_library")

string_flag(
    name = "vm_type",
    build_setting_default = "auto",
    values = [
        "auto",
        "direct",
        "call",
    ],
    visibility = ["//visibility:public"],
)

config_setting(
    name = "auto",
    flag_values = {":vm_type": "direct"},
)

config_setting(
    name = "direct",
    flag_values = {":vm_type": "direct"},
)

config_setting(
    name = "call",
    flag_values = {":vm_type": "call"},
)

cc_library(
    name = "graphite2",
    hdrs = [
        "include/graphite2/Font.h",
        "include/graphite2/Segment.h",
        "include/graphite2/Types.h",
        "include/graphite2/Log.h",
    ],
    srcs = select({
        ":auto": ["src/direct_machine.cpp"],
        ":direct": ["src/direct_machine.cpp"],
        ":call": ["src/call_machine.cpp"],
        "//conditions:default": ["src/direct_machine.cpp"],
    }) + [
        "src/CmapCache.cpp",
        "src/Code.cpp",
        "src/Collider.cpp",
        "src/Decompressor.cpp",
        "src/Face.cpp",
        "src/FeatureMap.cpp",
        "src/FileFace.cpp",
        "src/Font.cpp",
        "src/GlyphCache.cpp",
        "src/GlyphFace.cpp",
        "src/Intervals.cpp",
        "src/Justifier.cpp",
        "src/NameTable.cpp",
        "src/Pass.cpp",
        "src/Position.cpp",
        "src/Segment.cpp",
        "src/Silf.cpp",
        "src/Slot.cpp",
        "src/Sparse.cpp",
        "src/TtfUtil.cpp",
        "src/UtfCodec.cpp",
        "src/gr_char_info.cpp",
        "src/gr_face.cpp",
        "src/gr_features.cpp",
        "src/gr_font.cpp",
        "src/gr_logging.cpp",
        "src/gr_segment.cpp",
        "src/gr_slot.cpp",
        "src/json.cpp",
    ],
    textual_hdrs = [
        "src/inc/CharInfo.h",
        "src/inc/CmapCache.h",
        "src/inc/Code.h",
        "src/inc/Collider.h",
        "src/inc/Compression.h",
        "src/inc/Decompressor.h",
        "src/inc/Endian.h",
        "src/inc/Error.h",
        "src/inc/Face.h",
        "src/inc/FeatureMap.h",
        "src/inc/FeatureVal.h",
        "src/inc/FileFace.h",
        "src/inc/Font.h",
        "src/inc/GlyphCache.h",
        "src/inc/GlyphFace.h",
        "src/inc/Intervals.h",
        "src/inc/List.h",
        "src/inc/Machine.h",
        "src/inc/Main.h",
        "src/inc/NameTable.h",
        "src/inc/Pass.h",
        "src/inc/Position.h",
        "src/inc/Rule.h",
        "src/inc/Segment.h",
        "src/inc/Silf.h",
        "src/inc/Slot.h",
        "src/inc/Sparse.h",
        "src/inc/TtfTypes.h",
        "src/inc/TtfUtil.h",
        "src/inc/UtfCodec.h",
        "src/inc/bits.h",
        "src/inc/debug.h",
        "src/inc/json.h",
        "src/inc/locale2lcid.h",
        "src/inc/opcode_table.h",
        "src/inc/opcodes.h",
    ],
    includes = [
        "include",
        "src",
    ],
    visibility = ["//visibility:public"],
    copts = [
        "-Wno-deprecated-declarations",
        "-Wno-deprecated-enum-enum-conversion"
    ],
)
